package com.centaur0.tags;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;

public class AjaxTag extends SimpleTagSupport {
	public static final String AJAX_DIV_NAME = "com.centaur0.tags.AjaxTag._ajax_div";
	
	@Override
	public void doTag() throws JspException, IOException {
		if(!Boolean.TRUE.equals(getJspContext().getAttribute(AJAX_DIV_NAME, PageContext.REQUEST_SCOPE))){
			getJspContext().setAttribute(AJAX_DIV_NAME, Boolean.TRUE, PageContext.REQUEST_SCOPE);
			getJspContext().getOut().append(String.format("<div id='%s' style='position:relative;'></div>", AJAX_DIV_NAME));
		}
		getJspBody().invoke(getJspContext().getOut());
	}
}
